//
//  YMBaseViewController.swift
//  YMWeiBo
//
//  Created by mimi on 16/7/19.
//  Copyright © 2016年 mimi. All rights reserved.
//

import UIKit

class YMBaseViewController: UIViewController {
    
    
    

    override func viewDidLoad() {
        super.viewDidLoad()

        
        
    }
    
    override func loadView() {
        
        isLogin ? (view = tableView) : setupVisitorView()
        
//        view = tableView
    }
    
    func setupVisitorView() {
        
        visitorView = YMVisitorView()
        
        view = visitorView
        visitorView?.closure = {[weak self] in
            
            self?.didClickBt()
            
        }
    
        setupNavItem()
        
    }
    //        MARK: - =============设置=========
    
    func setupNavItem() {
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", imgName: nil, targe: self, action: #selector(YMBaseViewController.didClickBt))
        
        navigationItem.rightBarButtonItem = YMBarButtonItem(title: "注册", imgName: nil, targe: self, action: #selector(YMBaseViewController.didClickBt))
        
    }
    
    //        MARK: - ===========响应事件============
    
    //nav上面的登录注册
   @objc private func didClickBt () {

    let oauthVc:YMOAuthViewController = YMOAuthViewController()
   
    presentViewController( UINavigationController(rootViewController: oauthVc), animated: true, completion: nil)

    
    }

    //        MARK: - ========== 属性声明 ==========
    //判断是否登录
//    var isLogin:Bool = true
    // 判断用户是否登录
    var isLogin: Bool = YMUserAccountViewModel.sharedTools.isLogin
//    //访问视图view
    var visitorView:YMVisitorView?
    
    
    
    
    
    
    
    
    
    //        MARK: -============= 懒加载控件 =============
    lazy var tableView:UITableView = UITableView()
}
